import {JSEncrypt} from "jsencrypt";

const publicKey: string = import.meta.env.VITE_APP_PUBLIC_KEY
const devicePublicKey: string = import.meta.env.VITE_APP_DEVICE_PUBLIC_KEY

const RSACoder = {
    encrypt(data: string): string | false {
        let encrypt = new JSEncrypt();
        encrypt.setPublicKey(publicKey);
        return encrypt.encrypt(new Date().getTime() + data);
    },
    encryptDevice(data: string): string | false {
        let encrypt = new JSEncrypt();
        encrypt.setPublicKey(devicePublicKey);
        return encrypt.encrypt(new Date().getTime() + data);
    }
}
export default RSACoder;
